Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add use-layers rule #27

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

feat: Add use-layers rule #27

wants to merge 7 commits into from

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Dec 4, 2024

Prerequisites checklist

What is the purpose of this pull request?

Add a new use-layers rule

What changes did you make? (Give an overview)

  • Added use-layers rule
  • Added tests
  • Added docs
  • Ensured the rule is exported from the plugin

Note: This rule is not recommended because it will likely only be useful on a subset of CSS files in any given project.

Related Issues

fixes #18

Is there anything you'd like reviewers to focus on?

@jeddy3
Copy link

jeddy3 commented Dec 4, 2024

Looks great!

Should @import require a layer by default? Right now it doesn't, but I feel like maybe it should.

I think so. I had the same thought before seeing this PR.

@nzakas
Copy link
Member Author

nzakas commented Dec 4, 2024

@fasttime I can't quite figure out why the type tests are failing now. Can you take a look?

@nzakas
Copy link
Member Author

nzakas commented Dec 4, 2024

@jeddy3 thanks, updated!

@nzakas
Copy link
Member Author

nzakas commented Dec 4, 2024

I think I figured out the types issue: #28

src/rules/use-layers.js Outdated Show resolved Hide resolved
@nzakas nzakas marked this pull request as ready for review December 5, 2024 19:09
@nzakas
Copy link
Member Author

nzakas commented Dec 5, 2024

I fixed the bug in CSS Tree with layer positioning. Just waiting for a new release to update this PR.

@fasttime fasttime added the accepted There is consensus among the team that this change meets the criteria for inclusion label Dec 6, 2024
Copy link

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added two suggestions for extra tests.

I think I'd find it more intuitive if the boolean options matched, i.e. both made the rule stricter or more permissive.

For example, either:

  • allowUnnamedLayers: false
  • allowUnLayeredImports: false

or:

  • requireNamedLayers: true
  • requireImportLayers: true

tests/rules/use-layers.test.js Show resolved Hide resolved
tests/rules/use-layers.test.js Show resolved Hide resolved
@nzakas
Copy link
Member Author

nzakas commented Dec 6, 2024

With CSSTree updated, all of the locations are now correct. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion feature
Projects
Status: Implementing
Development

Successfully merging this pull request may close these issues.

New Rule: use-layers
3 participants